package com.xiaoxin.nmzp.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoxin.nmzp.server.entity.domain.NmzpCompany;
import com.xiaoxin.nmzp.server.entity.domain.NmzpJob;
import com.xiaoxin.nmzp.server.entity.resp.CompanyResp;
import com.xiaoxin.nmzp.server.mapper.NmzpJobMapper;
import com.xiaoxin.nmzp.server.service.NmzpCompanyService;
import com.xiaoxin.nmzp.server.mapper.NmzpCompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author xiaoxin
* @description 针对表【nmzp_company】的数据库操作Service实现
* @createDate 2024-11-05 08:44:41
*/
@Service
public class NmzpCompanyServiceImpl extends ServiceImpl<NmzpCompanyMapper, NmzpCompany>
    implements NmzpCompanyService{

    @Autowired
    private NmzpJobMapper nmzpJobMapper;

    /**
     * 根据公司id获取公司信息及职位信息
     *
     * @param companyId
     * @return
     */
    @Override
    public CompanyResp getCompanyAndJobsById(Long companyId) {
        NmzpCompany nmzpCompany = baseMapper.selectById(companyId);
        LambdaQueryWrapper<NmzpJob> jobLambdaQueryWrapper = new LambdaQueryWrapper<>();
        jobLambdaQueryWrapper.eq(NmzpJob::getCompanyId, companyId);
        List<NmzpJob> nmzpJobs = nmzpJobMapper.selectList(jobLambdaQueryWrapper);
        return new CompanyResp(nmzpCompany, nmzpJobs);
    }
}




